<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>Location Schema</title>
		<meta name="generator" content="Studio 3 http://aptana.com/" />
		<meta name="author" content="Gavin Koh" />
		<!-- Date: 2011-08-12 -->

		<!--Load Go ID's-->
		<!--<script type="text/javascript" src="js/eukaryote_schema.js"></script>-->
		<script type="text/javascript" src="js/is_extracellular.min.js"></script>
		<script type="text/javascript" src="js/is_cell_wall.min.js"></script>
		<script type="text/javascript" src="js/is_outer_membrane.js"></script>
		<script type="text/javascript" src="js/is_periplasm.js"></script>
		<script type="text/javascript" src="js/is_plasma_membrane.min.js"></script>
		<script type="text/javascript" src="js/is_cytoplasm.min.js"></script>
		<script type="text/javascript" src="js/is_mitochondrion.min.js"></script>
		<script type="text/javascript" src="js/is_chloroplast.min.js"></script>
		<script type="text/javascript" src="js/is_nucleus.min.js"></script>
		<script type="text/javascript"><!--
			function getCompartment() {
				var uniprotID = document.getElementById("searchTerm").value;
				var query = '?format=tsv&aspect=C&protein=' + uniprotID;
				var ajax = window.XMLHttpRequest?new XMLHttpRequest():new ActiveXObject("Microsoft.XMLHTTP");
				var getCellularCompartment = function(goId) {
					for (k in goId) {
						if ( isNucleus[goId[k]] ) {
							return 8;
						} else if ( isChloroplast[goId[k]] ) {
							return 7;
						} else if ( isMitochondrion[goId[k]] ) {
							return 6;
						} else if ( isCellWall[goId[k]] ) {
							return 1;
						} else if ( isExtracellular[goId[k]] ) {
							return 0;
						} else if ( isOuterMembrane[goId[k]] ) {
							return 2;
						} else if ( isPeriplasm[goId[k]] ) {
							return 3;
						} else if ( isPlasmaMembrane[goId[k]] ) {
							return 4;
						} else if ( isCytoplasm[goId[k]] ) {
							return 5;
						} else { 
							//Do nothing and try again
						};
					};
					return undefined; //Return undefined if no location found
				};
				ajax.onreadystatechange=function() {
					var responseSlices, responseSlicedSlices = [];
					if (ajax.readyState==4 && ajax.status==200) {
						document.getElementById("result").innerHTML=ajax.responseText;
						responseSlices = ajax.responseText.match(/(GO:\d{7})/gm);
						document.getElementById("list").innerHTML = responseSlices.toString();
						cl = getCellularCompartment(responseSlices);
						document.getElementById("locationCode").innerHTML = cl;
						document.getElementById("uniprotID").innerHTML = uniprotID;
						//Blank the results first
						document.getElementById("extracellular").innerHTML = '';
						document.getElementById("cellWall").innerHTML = '';
						document.getElementById("outerMembrane").innerHTML = '';
						document.getElementById("periplasm").innerHTML = '';
						document.getElementById("plasmaMembrane").innerHTML = '';
						document.getElementById("cytoplasm").innerHTML = '';
						document.getElementById("chloroplast").innerHTML = '';
						document.getElementById("mitochondrion").innerHTML = '';
						document.getElementById("nucleus").innerHTML = '';
						switch (cl) {
							case (0): {
								document.getElementById("extracellular").innerHTML = 'true';
								break;
							};
							case (1): {
								document.getElementById("cellWall").innerHTML = 'true';
								break;
							};
							case (2): {
								document.getElementById("outerMembrane").innerHTML = 'true';
								break;
							};
							case (3): {
								document.getElementById("periplasm").innerHTML = 'true';
								break;
							};
							case (4): {
								document.getElementById("plasmaMembrane").innerHTML = 'true';
								break;
							};
							case (5): {
								document.getElementById("cytoplasm").innerHTML = 'true';
								break;
							};
							case (7): {
								document.getElementById("chloroplast").innerHTML = 'true';
								break;
							};
							case (6): {
								document.getElementById("mitochondrion").innerHTML = 'true';
								break;
							};
							case (8): {
								document.getElementById("nucleus").innerHTML = 'true';
								break;
							};
							document.getElementById("array") = isOuterMembraneString;
						};
					};
				};
				ajax.open("GET",'http://www.ebi.ac.uk/QuickGO/GAnnotation'+query,true);
				ajax.send();
			}; 
		-->
		</script>
		<style>
			body { font-family: Georgia, Times, Roman; }
			dt { font-weight: bold; }
			.info { color: blue; }
		</style>
	</head>
	<body>
		<div style="width: 100%;">
			<h1>Location</h1>
			Type in a UniProt ID: <input type="text" id="searchTerm" value="P37173" onchange="getCompartment()"/>
			<input type="button" value="Press to search" onclick="getCompartment()"/>
		</div>
		<div style="float: right; width: 33%; padding: 3%; margin: 3%; border: solid 1px;">
			<p style="font-weight: bold;"><span id="uniprotID"></span> is part of:</p>
			<p>Extracellular: <span id="extracellular" class="info"></span></p>
			<p>Cell wall: <span id="cellWall" class="info"></span></p>
			<p>Outer membrane: <span id="outerMembrane" class="info"></span></p>
			<p>Periplasmic space: <span id="periplasm" class="info"></span></p>
			<p>Plasma membrane (=inner membrane): <span id="plasmaMembrane" class="info"></span></p>
			<p>Cytoplasm (=intracellular): <span id="cytoplasm" class="info"></span></p>
			<p>Chloroplast: <span id="chloroplast" class="info"></span></p>
			<p>Mitochondrion: <span id="mitochondrion" class="info"></span></p>
			<p>Nucleus: <span id="nucleus" class="info"></span></p>
			<p>Location code: <span id="locationCode"></span></p>
		</div>
		<div style=" padding: 5%;">
			<h3>Examples:</h3>
			<dl compact="true">
				<dt>P17497</dt><dd><i>Disintegrin bitan</i> African puff adder venom (maps to <em>extracellular</em>)</dd>
				<dt>Q9P378</dt><dd>1,3-beta-glucanosyltransferase <i>Schizosaccharomyces pombe</i> (<em>cell wall</em>)</dd>
				<dt>P75820</dt><dd>N-acetylmuramoyl-L-alanine amidase <i>Escherichia coli</i> (<em>outer membrane</em>)</dd>
				<dt>P05364</dt><dd><i>AmpC</i> beta-lactamase <i>Enterobacter cloacae</i> (<em>periplasmic space</em>)</dd>
				<dt>Q9QUK6</dt><dd><i>Tlr4</i> mouse Toll-like receptor 4 (<em>plasma membrane</em>)</dd>
				<dt>P53363</dt><dd>Ribosomal RNA small subunit methyltransferase G <i>Borrelia burgdorferi</i> (<em>cytosol</em>)</dd>
				<dt>GO:0000262</dt><dd>mitochondrial chromosome (<em>mitochondrion</em>)</dd>
				<dt>GO:0042648</dt><dd>chloroplast chromosome (<em>chloroplast</em>)</dd>
				<dt>GO:0005697</dt><dd>telomerase holoenzyme complex (<em>nucleus</em>)</dd>
			</dl>
			<h1>Notes</h1>
			<ol>
				<li>GO Cellular Component is not a tree. GO IDs may have multiple parents, which means there
					are duplicates in each of the terms. The terms are therefore searched in this order:
					<ol type="a">
						<li>Cell wall</li>
						<li>Nucleus</li>
						<li>Chloroplast</li>
						<li>Mitochondrion</li>
						<li>Extracellular</li>
						<li>Outer membrane (must be below nucleus, chloroplast and mitochondrion)</li>
						<li>Periplasmic space</li>
						<li>Plasma membrane</li>
						<li>Cytoplasm</li>
					</ol>
					The search is stopped as soon as a match is found.
				</li>
			</ol>
			<h3>Debugging:</h3>
			<ol>
				<li>AJAX query result:<br />
					<pre id="result"></pre>
				</li>
				<li>List of GO IDs:<br />
					<pre id="list"></pre>
				</li>
				<li>Associative array:<br />
					<pre id="array"></pre>
				</li>
			</ol>
		</div>
	</body>
</html>
